package com.ra.landlord;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Index;
import org.hibernate.annotations.Where;

import com.ra.system.Version;

/**
 * 抄表： 水表， 电表，热水表等
 * 
 * @author Jerry.Feng Date: 2014-07-31
 */
@Entity
@Table(name = "ra_meter")
/*@Where(clause = "data_status = 1")*/
public class Meter implements Version, LandlordOwner {
	
	private Integer id;
	
	// 当前刻度
	private BigDecimal count;
	
	// 单价
	private BigDecimal  price;
	
	// 抄表时间
	private Date checkTime;
	
	// 计费规则
	private FeeRule feeRule;
	
	// 是否可被删除
	private Boolean deletable;

	// 抄表员
	private LandlordUser reader;
	
	private LandlordOwnerUser landlordUser;
	
	private Integer version;
	
	private Integer status;
	
	@Id
	@GeneratedValue
	@Column(name = "MeterId")
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "MeterCount")
	public BigDecimal getCount() {
		return count;
	}

	public void setCount(BigDecimal count) {
		this.count = count;
	}

	@Column(name = "price")
	public BigDecimal getPrice() {
		return price;
	}

	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	@Column(name = "check_time")
	public Date getCheckTime() {
		return checkTime;
	}

	public void setCheckTime(Date checkTime) {
		this.checkTime = checkTime;
	}
		
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name = "relationId")
	@Index(name="idx_ra_meter_relationId")
	public FeeRule getFeeRule() {
		return feeRule;
	}

	public void setFeeRule(FeeRule feeRule) {
		this.feeRule = feeRule;
	}
	
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name = "admin_id")
	public LandlordUser getReader() {
		return reader;
	}

	public void setReader(LandlordUser reader) {
		this.reader = reader;
	}

	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name = "createuserid")
	public LandlordOwnerUser getLandlordUser() {
		return landlordUser;
	}

	public void setLandlordUser(LandlordOwnerUser landlordUser) {
		this.landlordUser = landlordUser;
	}

	@Column(name = "version_id")
	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	@Column(name = "data_status")
	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}	
	
	@Transient
	public Boolean getDeletable() {
		return deletable;
	}

	public void setDeletable(Boolean deletable) {
		this.deletable = deletable;
	}
}
